home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 May & June / Amiga-CD 1996 #5-6.iso / demos / finaldata / fdmacros / fittowindow < prev    next >
Text File  |  1996-03-22  |  2KB  |  62 lines

  1. /* ================================================= */
  2. /* Final Data ARexx Macro                            */
  3. /* FitToWindow - Fit all columns into the window.    */
  4. /* $VER: FitToWindow 1.0 (3.8.94)                    */
  5. /* © 1994 SoftWood, Inc.                             */
  6. /* Use of this macro is strictly at the user's risk. */
  7. /* ================================================= */
  8. OPTIONS RESULTS
  9.  
  10. minColumnWidth = 20     /* Minimum size to make a column (in screen pixels) */
  11. rowHdrWidth    = 57     /* Width of row numbers - for low res screens use 69 */
  12. scrollBarWidth = 18     /* Width of the right scroll bar. */
  13.  
  14.  
  15. /* ------------------------------------------------------- */
  16. /* Get the number of columns. If 0 the exit with an error. */
  17. /* ------------------------------------------------------- */
  18. NumColumns
  19. ncols = RESULT
  20. IF ( ncols = 0 ) THEN DO
  21.    ShowMessage 1 1 '"No columns defined." "" "" "OK" "" ""'
  22.    EXIT 10
  23. END
  24.  
  25. /* ------------------------------------------------ */
  26. /* Get the window's width and subtract off the area */
  27. /* for the row buttons and the right scroll bar.    */
  28. /* ------------------------------------------------ */
  29. GetWindowInfo
  30. windowWidth = WORD(RESULT, 3)
  31. dbWidth = windowWidth - rowHdrWidth - scrollBarWidth
  32.  
  33. /* --------------------------------------------------- */
  34. /* To find the new column widths divide dbWidth by the */
  35. /* number of columns. Make sure the column width is    */
  36. /* not smaller than our minimum column width.          */
  37. /* --------------------------------------------------- */
  38. colWidth = dbWidth % ncols
  39. IF ( colWidth < minColumnWidth ) THEN
  40.    colWidth = minColumnWidth
  41.  
  42. /* ---------------------------------------------------------------- */
  43. /* Turn off current selection. If we can't then exit with an error. */
  44. /* ---------------------------------------------------------------- */
  45. SelectOff
  46. IF ( RC ~= 0 ) THEN DO
  47.    ShowMessage 1 1 '"Cannot continue." "Check cell for invalid data." "" "OK" "" ""'
  48.    EXIT 10
  49. END
  50.  
  51. /* ----------------------------------------------------- */
  52. /* Set the width of each column to our new column width. */
  53. /* ----------------------------------------------------- */
  54. DO c = 1 to ncols
  55.    GetColumnID POSITION c
  56.    InitModifyColumn RESULT
  57.    DefineColumn WIDTH colWidth
  58.    ModifyColumn
  59. END   /* DO c */
  60.  
  61.  
  62. /* End of file */